package com.shiliang.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.shiliang.common.annotation.Log;
import com.shiliang.common.core.controller.BaseController;
import com.shiliang.common.core.domain.AjaxResult;
import com.shiliang.common.enums.BusinessType;
import com.shiliang.domain.MapData;
import com.shiliang.service.IMapDataService;
import com.shiliang.common.utils.poi.ExcelUtil;
import com.shiliang.common.core.page.TableDataInfo;

/**
 * 地图Controller
 * 
 * @author shiliang
 * @date 2025-07-17
 */
@RestController
@RequestMapping("/MapData/MapData")
public class MapDataController extends BaseController
{
    @Autowired
    private IMapDataService mapDataService;

    /**
     * 查询地图列表
     */
    @GetMapping("/list")
    public TableDataInfo list(MapData mapData)
    {
        startPage();
        List<MapData> list = mapDataService.selectMapDataList(mapData);
        return getDataTable(list);
    }

    /**
     * 导出地图列表
     */
    @PreAuthorize("@ss.hasPermi('MapData:MapData:export')")
    @Log(title = "地图", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MapData mapData)
    {
        List<MapData> list = mapDataService.selectMapDataList(mapData);
        ExcelUtil<MapData> util = new ExcelUtil<MapData>(MapData.class);
        util.exportExcel(response, list, "地图数据");
    }

    /**
     * 获取地图详细信息
     */
    @PreAuthorize("@ss.hasPermi('MapData:MapData:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(mapDataService.selectMapDataById(id));
    }

    /**
     * 新增地图
     */
    @PreAuthorize("@ss.hasPermi('MapData:MapData:add')")
    @Log(title = "地图", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MapData mapData)
    {
        return toAjax(mapDataService.insertMapData(mapData));
    }

    /**
     * 修改地图
     */
    @PreAuthorize("@ss.hasPermi('MapData:MapData:edit')")
    @Log(title = "地图", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MapData mapData)
    {
        return toAjax(mapDataService.updateMapData(mapData));
    }

    /**
     * 删除地图
     */
    @PreAuthorize("@ss.hasPermi('MapData:MapData:remove')")
    @Log(title = "地图", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mapDataService.deleteMapDataByIds(ids));
    }
}
